#include "vlog.h"

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

void log(int prio, const char * LEVEL_TAG, const char *format, ...) {
    const int MAX_LOG_LEN = 128;
    char logstr[MAX_LOG_LEN];
    va_list vlArgs;
    va_start(vlArgs, format);
    vsnprintf(logstr, MAX_LOG_LEN, format, vlArgs);
    va_end(vlArgs);

    #ifdef __ANDROID__
    __android_log_print(prio, LOG_TAG, "%s", logstr);
    #else
    fprintf(stderr, "%s %s\n", LEVEL_TAG, logstr);
    #endif
}
